package org.mysocial.services.dao.impl;

import java.util.List;

import javax.ejb.Local;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.mysocial.datamodel.Account;
import org.mysocial.datamodel.Post;
import org.mysocial.services.dao.PostDAO;

@Local(PostDAO.class)
@SuppressWarnings("unchecked")
@Stateless(name = PostDAO.EJB_NAME)
public class PostDAOImpl extends AbstractGenericDAO<Post, Long> implements
    PostDAO
{
	@Override
	public List<Post> getAccountPosts(Account account)
	{
		return entityManager.createNamedQuery(Post.GET_ACCOUNT_POSTS)
		    .setParameter(0, account).getResultList();
	}

	@Override
	@PersistenceContext
	public void setEntityManager(EntityManager entityManager)
	{
		this.entityManager = entityManager;
	}
}
